In [14]:
import sys
sys.path.append('../') # needed to run the examples from within the package folder
from pyrhythm.library import patterns_as_list
from pyrhythm import Pattern
from pyrhythm.metrics import LHL
from pyrhythm.metrics import offBeatness
from IPython.display import HTML
htmlTable = """<table>
<tr>
<td>Pattern Name</td>
<td>LHL</td>
<td>LHL/beat</td>
<td>offBeatness</td>
<td>offBeatness/beat</td>
</tr>
"""
for pat in [Pattern(**p) for p in patterns_as_list]:
s = LHL(pat)
nb = pat.num_bars()*pat.numerator
ob = offBeatness(pat)
list_to_display = (pat.name, s, float(s)/nb, ob, ob/nb)
# print "{: <35}\t{:2.0f}\t{:02.2f}\t{:2.0f}\t{:2.2f}".format(*list_to_display)
htmlTable += "<tr><td>"
htmlTable += "</td><td>".join("{}".format(k) for k in list_to_display)
htmlTable += "</td></tr>"
htmlTable += "</table>"
h = HTML(htmlTable); h
Out[14]:
In [ ]: